<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   
         <br />
         <input type="checkbox" name="love" />运动
        <input type="checkbox" name="love" />唱歌
         <input type="checkbox" name="love" />写代码
         <input type="checkbox" id="boxid" onclick="setAll()" />全选
         <input type="button" value="现在提交" disabled=true id=stemp onclick="submit()" />
         <script>
           function setAll(){var a=0;
             var box = document.getElementById("boxid");
             var loves = document.getElementsByName("love");
             var stemps = document.getElementById("stemp");
             if(box.checked == false){
                 for (var i = 0; i < loves.length; i++) {
                     loves[i].checked = false;
                 }
             }else{
                 for (var i = 0; i < loves.length; i++) {
                     loves[i].checked = true;
                     }
             }
             for(var i = 0; i < loves.length; i++){
                loves[i].onclick=function(){
                    if(!this.checked){
                        box.checked=false;
                    }
                   else
                   a++;
                if(a==loves.length){
                    box.checked=true;
                }
              if(a>=1)
              stemps.disabled=false;
                }
             }
         }
         </script>
</body>
</html>